package org.endy.leisure.diaTracker.config

import cn.binarywang.wx.miniapp.api.WxMaService
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class WxMaConfig(private val config: WxMaConfigurationProperties) {

    @Bean
    fun wxMaService(): WxMaService {
        val config = WxMaDefaultConfigImpl().apply {
            appid = config.appId
            token = config.token
            secret = config.secret
            aesKey = config.aesKey
        }
        return WxMaServiceImpl().apply {
            wxMaConfig = config
        }
    }

}
